/*
 * texture.h
 */

#ifndef TEXTURE_H_
#define TEXTURE_H_

#ifdef __APPLE_CC__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

#include <lua/luaR.h>

struct texture {
    GLuint id;
    GLsizei width;
    GLsizei height;
};

/*
 * Attempts to load the given filename as a PNG texture and insert the texture
 * into the given slot of the terrain texture array.
 */
int texture_load_terrain( const char *filename, int index );

/*
 * Attempts to load the given filename as a PNG texture.
 * Returns the texture ID if successful.
 */
int texture_load_unit( const char *filename );

/*
 * Returns the texture structure located at the given index of the terrain
 * texture array.
 */
struct texture texture_get_terrain( int i );

/*
 * Returns the texture structure located at the given index of the unit texture
 * attary.
 */
struct texture texture_get_unit( int i );

/*
 * Lua hook for the function
 * texture_load_terrain( const char *filename, int index )
 */
int texture_lua_load_terrain( lua_State *L );

/*
 * Calls the Lua function "loadTextures", which should load all the textures
 * used as terrain.
 */
void texture_load_textures();

/*
 * Initialize the texture module. Attempts to load and execute the Lua script
 * located at "scripts/texture.lua".
 */
int texture_init();

#endif
